home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / gnustuff / tos / updates / update15.zoo / pml / pmlsrc / cmult.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-02-04  |  1.8 KB  |  84 lines

  1. /************************************************************************
  2.  *                                    *
  3.  *                N O T I C E                *
  4.  *                                    *
  5.  *            Copyright Abandoned, 1987, Fred Fish        *
  6.  *                                    *
  7.  *    This previously copyrighted work has been placed into the    *
  8.  *    public domain by the author (Fred Fish) and may be freely used    *
  9.  *    for any purpose, private or commercial.  I would appreciate    *
  10.  *    it, as a courtesy, if this notice is left in all copies and    *
  11.  *    derivative works.  Thank you, and enjoy...            *
  12.  *                                    *
  13.  *    The author makes no warranty of any kind with respect to this    *
  14.  *    product and explicitly disclaims any implied warranties of    *
  15.  *    merchantability or fitness for any particular purpose.        *
  16.  *                                    *
  17.  ************************************************************************
  18.  */
  19.  
  20.  
  21. /*
  22.  *  FUNCTION
  23.  *
  24.  *    cmult   double precision complex multiplication
  25.  *
  26.  *  KEY WORDS
  27.  *
  28.  *    cmult
  29.  *    complex functions
  30.  *    machine independent routines
  31.  *    math libraries
  32.  *
  33.  *  DESCRIPTION
  34.  *
  35.  *    Computes double precision complex result of multiplication of
  36.  *    first double precision complex argument by second double
  37.  *    precision complex argument.
  38.  *
  39.  *  USAGE
  40.  *
  41.  *    COMPLEX cmult (z1, z2)
  42.  *    COMPLEX z1;
  43.  *    COMPLEX z2;
  44.  *
  45.  *  PROGRAMMER
  46.  *
  47.  *    Fred Fish
  48.  *    Tempe, Az 85281
  49.  *    (602) 966-8871
  50.  *
  51.  *  INTERNALS
  52.  *
  53.  *    Computes cmult(z1,z2) from:
  54.  *
  55.  *        1.    Let z1 = a + j b
  56.  *            Let z2 = c + j d
  57.  *
  58.  *        2.    r_cmult = (a*c - b*d)
  59.  *            i_cmult = (a*d + c*b)
  60.  *
  61.  *        3.    Then cmult(z1,z2) = r_cmult + j i_cmult
  62.  *
  63.  */
  64.  
  65. #if defined (__M68881__) && !defined (_M68881)
  66. /*# define _M68881*/
  67. #endif
  68.  
  69. #include <stdio.h>
  70. #include <math.h>
  71. #include "pml.h"
  72.  
  73. COMPLEX cmult (z1, z2)
  74. COMPLEX z1;
  75. COMPLEX z2;
  76. {
  77.     COMPLEX result;
  78.  
  79.     result.real = (z1.real * z2.real) - (z1.imag * z2.imag);
  80.     result.imag = (z1.real * z2.imag) + (z2.real * z1.imag);
  81.  
  82.     return (result);
  83. }
  84.